home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 4 / The 640 Meg Shareware Studio CD-ROM Volume IV (Data Express)(1994).ISO / clang / 120_01.zip / NOBOOT.C < prev    next >
Text File  |  1993-06-01  |  3KB  |  104 lines

  1. /* HEADER: CUG120.22;
  2.    TITLE: NOBOOT;
  3.    DESCRIPTION: "Modifies a BDS C program .COM file so that the CCP is preserved
  4.     and a warm boot is not done on termination.";
  5.    KEYWORDS: warm boot,CCP;
  6.    SYSTEM: CP/M;
  7.    FILENAME: NOBOOT.C;
  8.    WARNINGS:"The library function topofmem returns a value which is 2100H bytes too large
  9.     (i.e. the value for the original, unmodified program.)";
  10.    CRC: 75FF;
  11.    AUTHORS: Leor Zolman;
  12.    COMPILERS: BDS;
  13. */
  14. /*
  15.     Given the name of a C-generated COM file (linked with the standard
  16.     distribution version of the C.CCC run-time package), this program
  17.     changes that COM file so that it does not perform a warm-boot after
  18.     its execution is complete, but instead preserves the CCP (Console
  19.     Command Processor) that is in memory when execution begins and
  20.     returns to the CCP directly following execution.
  21.  
  22.     Note that the "topofmem" library function always returns the address
  23.     of the base of the BDOS, even when the non-booting mechanism is in
  24.     effect. Once NOBOOT has been run on a program, the actual top of 
  25.     available user memory is 2100 (decimal) bytes less than the value
  26.     returned by "topofmem()" for that program.
  27. */
  28.  
  29. #include "bdscio.h"
  30.  
  31. main(argc,argv)
  32. char **argv;
  33. {
  34.     int fd;
  35.     int i;
  36.     char c;
  37.     char nambuf[30];
  38.     char workbuf[0x500];
  39.  
  40.     if (argc != 2) {
  41.         puts("Usage: noboot <C-generated COM file name>\n");
  42.         exit();
  43.     }
  44.  
  45.     for (i=0; (c = argv[1][i]) && c != '.'; i++)
  46.          nambuf[i] = c;
  47.     nambuf[i] = '\0';
  48.     strcat(nambuf,".COM");
  49.  
  50.     if ((fd = open(nambuf,2)) == ERROR) {
  51.         puts("Can't open: ");
  52.         puts(nambuf);
  53.         exit();
  54.     }
  55.  
  56.     i = read(fd,workbuf+0x100,8);
  57.     if (i != 8) puts("Couldn't read in at least 8 sectors...\n");
  58.  
  59.     workbuf[0x100] = 0x21;
  60.     workbuf[0x101] = 0x00;
  61.     workbuf[0x102] = 0x00;
  62.     workbuf[0x103] = 0x39;
  63.     workbuf[0x104] = 0x22;
  64.     workbuf[0x105] = 0x79;
  65.     workbuf[0x106] = 0x05;
  66.     workbuf[0x107] = 0xcd;
  67.     workbuf[0x108] = 0x34;
  68.     workbuf[0x109] = 0x01;
  69.     workbuf[0x10a] = 0xf9;
  70.  
  71.     workbuf[0x12f] = 0x2a;
  72.     workbuf[0x130] = 0x79;
  73.     workbuf[0x131] = 0x05;
  74.     workbuf[0x132] = 0xf9;
  75.     workbuf[0x133] = 0xc9;
  76.  
  77.     workbuf[0x134] = 0x2a;
  78.     workbuf[0x135] = 0x06;
  79.     workbuf[0x136] = 0x00;
  80.     workbuf[0x137] = 0x11;
  81.     workbuf[0x138] = 0xcc;
  82.     workbuf[0x139] = 0xf7;
  83.     workbuf[0x13a] = 0x19;
  84.     workbuf[0x13b] = 0xc9;
  85.     workbuf[0x13c] = 0x00;
  86.     workbuf[0x13d] = 0x00;
  87.     workbuf[0x13e] = 0x00;
  88.  
  89.     workbuf[0x443] = 0xc3;
  90.     workbuf[0x444] = 0x2f;
  91.     workbuf[0x445] = 0x01;
  92.  
  93.     seek(fd,0,0);
  94.     if (write(fd,workbuf+0x100,8) != 8) {
  95.         puts("Write error.\n");
  96.         exit();
  97.     }
  98.  
  99.     if (close(fd) == ERROR) {
  100.         puts("Close error\n");
  101.     }
  102. }
  103. his program
  104.     changes that COM file so that it does no